package com.atguigui.leetcode;


/**
 * 662.二叉树最大宽度
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by  wangjiaxin  on 2022/8/27 19:40
 */
public class P662MaximumWidthOfBinaryTree {
    public static void main(String[] args) {
        Solution solution = new P662MaximumWidthOfBinaryTree().new Solution();
        // TO TEST
    }

    class Solution {
        /*public int widthOfBinaryTree(TreeNode root) {
            int res = 1;
            List<Pair<TreeNode, Integer>> arr = new ArrayList<Pair<TreeNode, Integer>>();
            arr.add(new Pair<TreeNode, Integer>(root, 1));
            while (!arr.isEmpty()) {
                List<Pair<TreeNode, Integer>> tmp = new ArrayList<Pair<TreeNode, Integer>>();
                for (Pair<TreeNode, Integer> pair : arr) {
                    TreeNode node = pair.getKey();
                    int index = pair.getValue();
                    if (node.left != null) {
                        tmp.add(new Pair<TreeNode, Integer>(node.left, index * 2));
                    }
                    if (node.right != null) {
                        tmp.add(new Pair<TreeNode, Integer>(node.right, index * 2 + 1));
                    }
                }
                res = Math.max(res, arr.get(arr.size() - 1).getValue() - arr.get(0).getValue() + 1);
                arr = tmp;
            }
            return res;
        }*/
    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}
